/**
 * 任务管理页面
 */
var tmpl_query='\
		<div class="pane-form queryTable">\
				<ul>\
					<li><label>项目:\
							<select id="project">\
		 						<option value ="">所有项目</option>\
		 					</select>\
		 				</label>\
					</li>\
					<li><label>人员：<select id="user">\
									</select></label>\
					</li>\
					<li><label>任务状态：<select id="taskStatus">\
						</select></label>\
					</li>\
					<li><label>优先级：<select id="priority">\
							<option value ="">所有优先级</option>\
							<option value ="1">1</option>\
							<option value ="2">2</option>\
							<option value ="3">3</option>\
							<option value ="4">4</option>\
							<option value ="5">5</option>\
							<option value ="6">6</option>\
							<option value ="7">7</option>\
							<option value ="8">8</option>\
						</select></label>\
					</li>\
					<li><label>开发时间：<input size="12" type="text" id="startTime" readonly data-date-format="yyyy-mm-dd" class=" form_datetime" data-link-format="yyyy-mm-dd"></label>\
					</li>\
					<li><label>—</label>\
					</li>\
					<li><label><input size="12" type="text" id="endTime" readonly data-date-format="yyyy-mm-dd" class=" form_datetime" data-link-format="yyyy-mm-dd"></label>\
					</li>\
					<li><a class="btn btn-success btn-xs glyphicon glyphicon-search" id="queryBtn">查询</a></li>\
					<li><a class="btn btn-success btn-xs glyphicon glyphicon-repeat" id="resetBtn">重置</a></li>\
				</ul>\
		</div>';


// <li><a class="onBtn"></a></li>\
var tmpl_query_more='\
	<div class="pane-form-more queryTable">\
			<ul>\
				<li><label>任务ID：<input type="text" id="taskId"></label>\
				<li><label>音频语言代码：<input type="text" id="audioLanguageCode"></label>\
				</li>\
				<li><label>字幕语言代码：<input type="text" id="subtitleLanguageCode"></label>\
				</li>\
				<li><label>栏目代码：<input type="text" id="columnCode"></label>\
				</li>\
				<li><label>频道名称：<select type="" id="channelCode"></select></label>\
				</li>\
				<li><label>提交时间：<input size="12" type="text" id="submitStartTime" readonly data-date-format="yyyy-mm-dd" class=" form_datetime" data-link-format="yyyy-mm-dd">\
					</label>\
				</li>\
				<li><label>—</label>\
				</li>\
				<li><label><input size="12" type="text" id="submitEndTime" readonly data-date-format="yyyy-mm-dd" class=" form_datetime" data-link-format="yyyy-mm-dd"></label>\
				</li>\
				<li><label>优先级：<select id="priority">\
												<option value ="">所有优先级</option>\
												<option value ="1">1</option>\
												<option value ="2">2</option>\
												<option value ="3">3</option>\
												<option value ="4">4</option>\
												<option value ="5">5</option>\
												<option value ="6">6</option>\
												<option value ="7">7</option>\
												<option value ="8">8</option>\
											</select>\</label>\
				</li>\
				<li><label>质检Actor：<select id="actor">\
								 </select></label>\
				</li>\
				<li><label>质检视频得分：<input size="12" type="text" id="minVideoScore"></label>\
				</li>\
				<li><label>—</label>\
				</li>\
				<li><label><input size="12" type="text" id="maxVideoScore"></label>\
				</li>\
				<li><label>质检音频频得分：<input size="12" type="text" id="minAudioScore"></label>\
				</li>\
				<li><label>—</label>\
				</li>\
				<li><label><input size="12" type="text" id="maxAudioScore"></label>\
				</li>\
			</ul>\
	</div>';

var tmpl_list='\
	<div id="task_list_div" class="uqe-pane pane-list">\
		<header class="header">\
			<label>任务操作</label>\
			<div class="toolbar right">\
				<a id="exportTasks1" class="btn btn-success btn-xs glyphicon glyphicon-plus">添加项目任务</a>\
				<a id="exportTasks"  class="btn btn-success btn-xs glyphicon glyphicon-download">任务列表导出</a>\
			</div>\
		</header>\
		<div id="task_result_div" class="body">\
		</div>\
	<footer class="footer"></footer>\
	</div>';

var tmpl_method = '\
	<div class="methodDiv" id="right">\
		<form>\
			<ul>\
				<li><input type="button" class="buttonMethod" id ="deleteTask" value="任务删除                  "></input>\
				</li>\
				<li><input type="button" class="buttonMethod" id= "startTask" value="任务开始            "  ></input>\
				</li>\
				<li><input type="button" class="buttonMethod" id= "complateTask" value="任务完成             "  ></input>\
				</li>\
				<li><input type="button" class="buttonMethod" id= "modifyPriority" value="优先级调整   "  ></input>\
				</li>\
				<li><input type="button" class="buttonMethod" id= "updateUser" value="换人        "  ></input>\
				</li>\
				<li><input type="button" class="buttonMethod" id= "updatePlanEndTime" value="计划结束时间调整" ></input>\
			</ul>\
		</form>\
	</div>';

var validate_User = '\
	<div class="windowEdit uqe-pane">\
		<img src="../images/bt-close.png" class="edit_close">\
		<div class="header">\
			<label id ="vu_addUserLabel">用户验证</label>\
		</div>\
		<div class="body">\
        		<table class="infoTbl" >\
					<tr>\
						<td class="name">用户：</td>\
						<td>\
							<input class="user_input" type="text" disabled="disabled" id="vuserId">\
						</td>\
					</tr>\
					<tr>\
						<td class="name">密码：</td>\
						<td>\
							<input class="user_input" type="password" id="vupass">\
						</td>\
					</tr>\
				</table>\
		</div>\
		<footer class="footer" style="text-align: center;">\
			<a class="btn btn-success btn-xs glyphicon glyphicon-ok" id="userValdateBtn">确定</a>\
			<a class="btn btn-success btn-xs glyphicon glyphicon-trash">取消</a>\
		</footer>\
	</div>';

var tmpl_priority = '\
	<div class="windowEdit uqe-pane">\
	<img src="../images/bt-close.png" class="edit_close">\
	<div class="header">\
		<label>请选择优先级</label>\
	</div>\
	<div class="body">\
    		<table class="infoTbl" >\
				<tr>\
					<td class="name">优先级：</td>\
					<td><label>\
							<select id="prioritySel">\
								<option value ="1">1</option>\
								<option value ="2">2</option>\
								<option value ="3">3</option>\
								<option value ="4">4</option>\
								<option value ="5">5</option>\
								<option value ="6">6</option>\
								<option value ="7">7</option>\
								<option value ="8">8</option>\
							</select>\</label>\
					</td>\
				</tr>\
				<tr id="ActorHidden" hidden = "true">\
					<td class="name">指定Actor：</td>\
					<td>\
							<select id="assignActorA">\
							</select>\
					</td>\
				</tr>\
				<tr>\
					<td colspan ="2" id="actorDes" class="red_color" hidden = "true"></td>\
				</tr>\
			</table>\
	</div>\
	<footer class="footer" style="text-align: center;">\
		<a class="btn btn-success btn-xs glyphicon glyphicon-ok" id="priorityOK">确定</a>\
		<a class="btn btn-success btn-xs glyphicon glyphicon-trash" id="priorityCancel">取消</a>\
	</footer>\
</div>';

var tmpl_archive = '\
	<div class="windowEdit uqe-pane">\
	<img src="../images/bt-close.png" class="edit_close">\
	<div class="header">\
		<label>手动归档</label>\
	</div>\
	<div class="body">\
    		<table class="infoTbl" >\
				<tr>\
					<td class="name"><span class="red_color">*</span>请填写手动处理备注：</td>\
					<td><textarea id="failDescription" rows="6" cols="35"></textarea>\
					</td>\
				</tr>\
			</table>\
	</div>\
	<footer class="footer" style="text-align: center;">\
		<a class="btn btn-success btn-xs glyphicon glyphicon-ok" id="archiveOK">确定</a>\
		<a class="btn btn-success btn-xs glyphicon glyphicon-trash" id="archiveCancel">取消</a>\
	</footer>\
</div>';

var tmpl_detail = '\
	<div id="task_detail_div" class="uqe-pane pane-detail">\
		<header class="header">\
			<label>详细信息</label>\
		</header>\
		<div id="task_detail_body" class="body">\
		</div>\
		<footer id="savefooter" class="footer">\
			<a id="close_detail" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-share-alt"></span>关闭</a>\
		</footer>\
	</div>';





var tmpl_new = '\
	<div class="windowEdit uqe-pane">\
		<img src="../images/bt-close.png" class="edit_close">\
		<header class="header">\
			<label id="addUserLabel" >添加新任务</label>\
		</header>\
		<div class="body">\
			<form name="form2" method="post">\
        		<table class="infoTbl" >\
					<tr>\
						<td>\
							<span class="must_input">* \
						</td>\
						<td class="name">任务标题：</td>\
						<td>\
							<input class="user_input" type="text" id="taskTitle_new">\
						</td>\
					</tr>\
					<tr>\
						<td>\
							<span class="must_input">* \
						</td>\
						<td class="name">优先级：</td>\
						<td>\
							<select class="user_input" type="text" id="priority_new">\
										<option value ="1" default >1</option>\
										<option value ="2">2</option>\
										<option value ="3">3</option>\
										<option value ="4">4</option>\
										<option value ="5">5</option>\
										<option value ="6">6</option>\
										<option value ="7">7</option>\
										<option value ="8">8</option>\
							</select>\
						</td>\
					</tr>\
					<tr>\
						<td>\
						</td>\
						<td class="name">计划完成时间：</td>\
						<td>\
							<input size="12" type="text" id="plannedEndTime_new" readonly data-date-format="yyyy-mm-dd" class=" form_datetime" data-link-format="yyyy-mm-dd">\
						</td>\
					</tr>\
					<tr>\
						<td>\
							<span class="must_input">* \
						</td>\
						<td class="name">所属项目：</td>\
						<td>\
							<select class="user_input" type="text" id="project_new">\
							</select>\
						</td>\
					</tr>\
					<tr>\
						<td>\
						</td>\
						<td class="name">人员：</td>\
						<td>\
							<select class="user_input" type="text" id="user_new">\
							</select>\
						</td>\
					</tr>\
					<tr>\
						<td>\
						</td>\
						<td class="name">任务描述：</td>\
						<td>\
						<textarea cols="36" rows="5" id="description_new"  ></textarea>\
						</td>\
				</tr>\
					<tr>\
						<td>\
						</td>\
					</tr>\
				</table>\
			</form>\
		</div>\
		<footer class="footer" style="text-align: center;">\
				<a class="btn btn-success btn-xs glyphicon glyphicon-ok" id= "addNewTaskBnt">确定</a>\
				<a class="btn btn-success btn-xs glyphicon glyphicon-trash">取消</a>\
		</footer>\
	</div>';




var _order_columns = {
		'任务类型':'task_type',
		'优先级':'priority',
		'任务状态':'task_status',
		'所属项目名':'project_name',
		'项目使用单位':'use_unit',
		'项目使用地区':'use_area',
		'任务执行人':'user_name',
		'创建时间':'task_create_time',
		'计划结束时间':'planned_end_time',
		'任务开始时间':'start_time',
		'任务结束时间':'end_time'
};

var _search_columns = {
		'任务类型':'taskType',
		'优先级':'priority',
		'任务状态':'taskStatus',
		'所属项目名':'projectName',
		'项目使用单位':'useUnit',
		'项目使用地区':'useArea',
		'任务执行人':'userName',
		'创建时间':'taskCreateTime',
		'计划结束时间':'plannedEndTime',
		'任务开始时间':'startTime',
		'任务结束时间':'endTime'
			
  
//			private   String  projectId= null ;/**    任务所属项目     */
//			private   String  userId= null ;/**    分配执行人（用户）     */
//			private   String  taskDescription= null ;/**    任务功能详细描述     */
//			private   String  taskStatus= null ;/**         */
//			private   Date  projectCreateTime= null ;/**    项目创建时间     */
//			private   String  useUnit= null ;/**    项目使用单位     */
//			private   String  useArea= null ;/**    项目使用地区     */
//			private   String  rely= null ;/**    项目依赖其他产品的描述     */
//			private   String  gitPath= null ;/**    项目版本库地址     */
//			private   String  branch= null ;/**    项目版本库上的分支     */
//			private   String  userName= null ;/**    用户名称     */
//			private   String  password= null ;/**    用户密码，后期做登录时使用     */
//			private   String  sex= null ;/**    性别     */
//			private   String  roleName= null ;/**    角色名(暂时划分为 leader和developer)     */
//			private   String  userDescription= null ;/**    备注     */
			
		  
};

var channels = {};
var systemObj = {};

$(function(){
	
	var SEARCH_TABLE_COLUMNS = new Array();
	
	 
	SEARCH_TABLE_COLUMNS.push(" 任务类型");
	SEARCH_TABLE_COLUMNS.push("优先级");
	SEARCH_TABLE_COLUMNS.push("任务状态");
	SEARCH_TABLE_COLUMNS.push("所属项目名");
	SEARCH_TABLE_COLUMNS.push('项目使用单位');
	SEARCH_TABLE_COLUMNS.push(' 项目使用地区');
	SEARCH_TABLE_COLUMNS.push('任务执行人');
	SEARCH_TABLE_COLUMNS.push('创建时间');
	SEARCH_TABLE_COLUMNS.push('计划结束时间');
	SEARCH_TABLE_COLUMNS.push('任务开始时间');
	SEARCH_TABLE_COLUMNS.push("任务结束时间");
	
	
	
	
	
	var divQuery = $(tmpl_query).appendTo('body');
	var divQueryMore = $(tmpl_query_more).appendTo('body');
	var divList = $(tmpl_list).appendTo('body');
	var divMethod = $(tmpl_method).appendTo('body');
	var divPriority = $(tmpl_priority).appendTo('body');
	var divDetail = $(tmpl_detail).appendTo('body');
	var validate_User_dialog = $(validate_User).appendTo('body');
	var divArchive = $(tmpl_archive).appendTo('body');
	
	var divNew = $(tmpl_new).appendTo('body');
	
	divMethod.hide();
	var taskid;
	var _statusType;
	var type;
	var _task;
	var actorname;
	var md5ActorName;
	var pageSize = 100, pageNo = 1;
	var handleBtn;
	var asc = "ASC";
	var desc = "DESC";
	var orderByColumn = "";
	var orderByType = "";
	var isTask;
	$('<div class="black_overlay">').appendTo('body');
	
	divNew.find('.glyphicon-trash').click(function() {
		divNew.hide();
		$(".black_overlay").hide();
	});
	divNew.find('.edit_close').click(function() {
		divNew.hide();
		$(".black_overlay").hide();
	});
	
	
	var validateUser = function(){
		var user  = top.Proxy.getLoginUser();
		$('#vuserId').val(user.userId );
		$('#vupass').val('');
		
		$(".black_overlay").show();
		validate_User_dialog.show();
	};
	
	divQuery.find(".onBtn").click(function(){
		divQueryMore.toggleClass('normal');
		$(this).toggleClass('offBtn');
		divList.toggleClass('uqe-pane-normal');
		divDetail.toggleClass('uqe-pane-normal');
	});
	  
	$('#project').html("");
	var param = {};
	top.Proxy.generalPostAjax('projectInfo/query' , param ,  function(res) {
		 $('<option>').attr('value', '').html('所有项目').appendTo('#project');
			$(res.result).each(
					function(index, project) {
						$('<option>').attr('value', project.projectId  )
								.html(project.projectName).appendTo('#project');
					});
	}, function(e) {
			console.log( e )
		  alert("获取项目 出错");
	});
	
	$('#user').html("");
	var param = {};
	top.Proxy.generalPostAjax('user/query' , param ,  function(res) {
		 $('<option>').attr('value', '').html('所有人').appendTo('#user');
			$(res.result).each(
					function(index, user) {
						$('<option>').attr('value', user.userId  )
								.html(user.userName).appendTo('#user');
					});
	}, function(e) {
			console.log( e )
		  alert("获取用户 出错");
	});
	
	
	$('#taskStatus').html("");
	var param = {};
	top.Proxy.generalPostAjax('task/status' , param ,  function(res) {
		 $('<option>').attr('value', '').html('所有状态').appendTo('#taskStatus');
			$(res.result).each(
					function(index, status) {
						$('<option>').attr('value', status.value  )
								.html(status.name).appendTo('#taskStatus');
					});
	}, function(e) {
			console.log( e )
		  alert("获取状态出错");
	});
	
	
	
	
	
	
	divList.find('.glyphicon-plus').click(
			function() {
				$('#taskTitle_new').val('');
				$('#priority_new').val('');
				$('#plannedEndTime_new').val('');
				$('#project_new').val('');
				$('#user_new').val('');
				$('#description_new').val('');
 
				$(".glyphicon-saved").show();
				$("#addUserLabel").html("添加新任务"); 
				$(".black_overlay").show();
				
				divNew.show();
				// 填充角色下拉框
				var param = {};
				$('#project_new').html("");
				var param = {};
				top.Proxy.generalPostAjax('projectInfo/query' , param ,  function(res) {
						$(res.result).each(
								function(index, project) {
									$('<option>').attr('value', project.projectId  )
											.html(project.projectName).appendTo('#project_new');
								});
				}, function(e) {
						console.log( e )
					  alert("获取项目 出错");
				});
				
				$('#user_new').html("");
				var param = {};
				top.Proxy.generalPostAjax('user/query' , param ,  function(res) {
					 $('<option>').attr('value', '').html('').appendTo('#user_new');
						$(res.result).each(
								function(index, user) {
									$('<option>').attr('value', user.userId  )
											.html(user.userName).appendTo('#user_new');
								});
				}, function(e) {
						console.log( e )
					  alert("获取用户 出错");
				});
			});
	
	
	
	divNew.find('.glyphicon-ok').click(function() {

		var taskTitle = $('#taskTitle_new').val().trim();
		var priority = $('#priority_new').val().trim();
		var plannedEndTime = $('#plannedEndTime_new').val().trim();
		var project = $('#project_new').val();
		var user = $('#user_new').val();
		var description = $('#description_new').val();
		 
		if (taskTitle == null || taskTitle == '') {
			alert("请填写任务标题");
			return;
		}
		if (description == null || description == '') {
			alert("请填写任务描述");
			return;
		} 
		if (plannedEndTime == null || plannedEndTime == '') {
			alert("请填写任务计划完成时间");
			return;
		}
		var param = {
				taskTitle : taskTitle,
				priority : priority,
				plannedEndTime: new Date(plannedEndTime),
				projectId : project ,
				userId : user ,
				description:description
		};
		  
		 
		
		top.Proxy.generalPostAjax('task/add' , param ,  function(res) {
			alert("新建任务成功");
			{
				divNew.hide();
				$(".black_overlay").hide();
			}
			__queryList();
		}, function(e) {
			alert( e.message);
		});
		
		
		
	});
	
	divQuery.find('#queryBtn').click(function(){
		pageNo = 1;
		__queryList();
	});
	divQuery.find('#resetBtn').click(function(){
		pageNo = 1;
		
		$('#priority').val("");
		$('#project').val("");
		$('#user').val("");
		$('#taskStatus').val("");
		$("#startTime").val("");
		$("#endTime").val("");
	});
	var __queryList = function(){
		divList.find('tbody').empty();
		divList.find('footer').empty();
		divMethod.hide();
		var priority = $('#priority').val();
		var project = $('#project').val();
		var user = $('#user').val();
	 
		var taskStatus = $('#taskStatus').val();
		var startTime = $('#startTime').val();
		var endTime = $('#endTime').val();
		  
		
		var queryConditions = new Array();//查询条件
		if(orderByColumn == null || orderByColumn.trim().length == 0){
			orderByColumn = 'task_create_time';
		}
		if(orderByType == null || orderByType.trim().length == 0 ){
			orderByType = desc;
		}
		var data={
				 conditions:queryConditions,
				 relation: 'AND',
				 orderBy: [{
					 name: orderByColumn,
					 order: orderByType
				 }],
				 start: (pageNo-1) * pageSize,
				 limit: pageSize
		};
		 
		
		if(priority.length>0){
			data.conditions.push({
				name: 'priority',
				logic:'=',
				value: priority
			});
		}
		if(project.length>0){
			data.conditions.push({
				name: 'project_name',
				logic:'Like',
				value: '%'+project+'%'
			});
		}
		if(user.length>0){
			data.conditions.push({
				name: 'user_name',
				logic:'Like',
				value: '%'+user+'%'
			});
		}
		if(taskStatus.length>0){
			data.conditions.push({
				name: 'task_status',
				logic:'=',
				value: taskStatus
			});
		} 
		 
		
		if (startTime.length > 0 && endTime.length > 0) {
			var startT = new Date(submitStartTime);
			var endT = new Date(submitEndTime);
			if (startT > endT) {
				alert("结束日期不能小于开始日期");
			} else {

				data.conditions.push({
					name : 'start_time',
					logic : 'STARTTIME',
					value : "'" + startTime + "'"
				});
				data.conditions.push({
					name : 'start_time',
					logic : 'ENDTIME',
					value : "'" + endTime + "'"
				});
			}
		} else if (startTime.length > 0) {
			data.conditions.push({
				name : 'start_time',
				logic : 'STARTTIME',
				value : "'" + startTime + "'"
			});
		} else if (endTime.length > 0) {
			data.conditions.push({
				name : 'start_time',
				logic : 'ENDTIME',
				value : "'" + endTime + "'"
			});
		}
		  
		
		 
		top.Proxy.generalPostAjax('task/pageView' , data ,  function(res) {
			__queryResult(res);
		}, function(e) {
				console.log( e )
			  alert("分页查询任务出错");
		});
		
		
//		top.Proxy.getTasksView4page(data, function(res){
//			__queryResult(res);
//		}, function(){
//			
//		});
	};

	$('#task_result_table').html('');
	var table = $('<table id="task_result_table">').addClass('table').appendTo('#task_result_div');
	var _showColumn = function(){
		var th = $('<thead>').appendTo(table);
		var checkAll = $('<input type="checkbox" name="idAll" id="idAll">').click(function(){
			var b = this.checked;
			$("input[name='ids']").each(function() {
				$(this).attr("checked", b);
			});
		});
		$('<th>').html(checkAll).appendTo(th);
		$('<th style="width:140px">').html('任务说明').appendTo(th);
		$('<th style="width:100px;">').html('操作').appendTo(th);
		$(SEARCH_TABLE_COLUMNS).each(function(i,column){
			if(!_search_columns.hasOwnProperty(column)){
				return;
			}
			var td = $('<th>').html(column).appendTo(th);
			$('<img style="cursor:pointer;"  src="../images/desc.png"   id="'+_order_columns[column]+'"  order="asc">').click(function(){
				var val = $(this).attr("order");
				
				if(val == asc){
					$(this).attr("order", desc );
					$(this).attr("src","../images/desc.png");
				}else{
					$(this).attr("order", asc );
					$(this).attr("src","../images/asc.png");
				}
				var id  = $(this).attr("id" );
				 orderByColumn = id;
				 orderByType = $(this).attr("order");
				 __queryList();
			}).appendTo(td);
		});
	};
	
	_showColumn();
	$('<tbody>').appendTo(table);
	var __queryResult = function(res){
		$('#idAll').removeAttr("checked");
		var tobodyList = table.find('tbody');
		tobodyList.empty();
		$(res.result).each(function(index, task){
			var tr = $('<tr>').appendTo(tobodyList);
			var tdFirst = $('<td>').appendTo(tr);
			$('<input type="checkbox" name="ids">').attr('id',task.taskId).click(function(){
				var indexNum = 0;
				$(':input[name="ids"]').each(function(){
					if(!this.checked){
						indexNum ++;
					}
				 });
				if(indexNum > 0){
					$('#idAll').removeAttr("checked");
				}else{
					$('#idAll').attr("checked","checked");
				}
				event.stopPropagation();
			}).appendTo(tdFirst);
			$('<td>').html(task.taskTitle).appendTo(tr);
			var lastTd = $('<td>').appendTo(tr);
			$('<img class="opers" src="../images/operation.png">').bind('click',function(e){
				var pointx = e.pageX;
				var pointy = e.pageY;
//				var offset = $('#'+operationid).offset();
				//根据status定制操作面板的内容
				taskid = task.taskId;
				_statusType = task.statusType;
				__markOperationPanel( task );
				_task = task;
				if(e.pageY+ 450 > screen.height){
					divMethod.css('top',pointy-130).css('left',pointx-130).show();
				}else{
					divMethod.css('top',pointy).css('left',pointx-130).show();
				}
			}).hover(
					function() {$(this).attr('src','../images/operation-slide.png');},  
					function() {$(this).attr('src','../images/operation.png');}  		
			).appendTo(lastTd);
			
			var status= task.taskStatus;
			
			$(SEARCH_TABLE_COLUMNS).each(function(i,column){
				if(!_search_columns.hasOwnProperty(column)){
					return;
				}
				
				var showValue = task[_search_columns[column]];
				if(_search_columns[column]=="taskStatus"){
					if(status ==0){
						showValue = '<img  src="../images/status-wait.png"><span class="statusSpan">等待 </span>';
					}else if(status==1){
						showValue ='<img  src="../images/status-doing.gif"><span class="statusSpan">进行中</span>';
					}else if(status==2){
						showValue ='<img src="../images/status-doing.gif"><span class="statusSpan">--测试</span>';
					}else if(status==3){
						showValue ='<img src="../images/status-success.png"><span class="statusSpan">已完成</span>';
					}else{
						showValue ='<img src="../images/status-wait.png"></span>';
					}
				}
				 
				if(_search_columns[column]=="plannedEndTime"||_search_columns[column]=="taskCreateTime"
					||_search_columns[column]=="updateTime"
					||_search_columns[column]=="startTime"||_search_columns[column]=="endTime" )
				{
					if(task[_search_columns[column]] == null || task[_search_columns[column]] ==""){
						showValue == "";
					}else{
//						showValue = new Date(showValue).pattern("yyyy-MM-dd HH:mm:ss");
						showValue = new Date(showValue).pattern("yyyy-MM-dd");
//						var year  = new Date(task[_search_columns[column]]).getFullYear();
//						if(parseInt(year)==3000||parseInt(year)==1970){
//							showValue="";
//						}else{
//							if(_search_columns[column]=="playTime"){
//								if(new Date(showValue) < new Date()){
//									showValue = "";
//								}else{
//									showValue = new Date(showValue).pattern("yyyy-MM-dd HH:mm:ss");
//								}
//							}else{
//								showValue = new Date(showValue).pattern("yyyy-MM-dd HH:mm:ss");
//							}
//						}
					}
				}
				    
				if(_search_columns[column]=="description"){
					$('<td data-toggle="tooltip" data-placement="top">').attr('title',task.description).html(task.description.substr(0,40)).appendTo(tr) ;
				}else{
					$('<td>').html(showValue).appendTo(tr);
				}
			});

			tr.hover(  
					  function() {$(this).addClass('highlight');divMethod.hide();$(this).find('.opers').show();},  
					  function() {$(this).removeClass('highlight');$(this).find('.opers').hide();}  
					 ); 
			tr.click(function(){
				    $(this).siblings().removeClass('selected');  
				    $(this).toggleClass('selected');
				    var check = $(this).find(':checkbox');
				    var value= check.attr('checked');
				    check.attr('checked',!value);
				  
					var indexNum = 0;
					$(':input[name="ids"]').each(function(){
						if(!this.checked){
							indexNum ++;
						}
					 });
					if(indexNum > 0){
						$('#idAll').removeAttr("checked");
					}else{
						$('#idAll').attr("checked","checked");
					}
			});
//			i++;
			tr.dblclick(function(){
				$('#task_list_div').css('right','25%');
//				var taskParam  = {
//						taskId:task.taskId
//				};
//				if(task.isTask == 2){
//					getTaskLogById(taskParam);
//				}else{
//					getTaskById(taskParam);
//				}
				console.log( task );
				showTask(task_detail, task );
//				showFootPrints({});
				
				$('#task_detail_div').show();
//				$("task_detail_div").animate({left:"-100"},800); 
			});
		});
		__updatePages(res.total);
	};
	var task_detail = [{column:'taskId',name:'任务ID'},
						{column:'taskTitle',name:'任务类型'},
						 {column:'priority',name:'优先级'},
						  {column:'taskStatus',name:'任务状态'},
						  {column:'taskDescription',name:'功能详细描述'},
	                   {column:'projectName',name:'任务所属项目'},
	                   {column:'userName',name:'开发者'},
	                   {column:'roleName',name:'角色'},
	                   {column:'useUnit',name:' 项目使用单位'},
	                   {column:'useArea',name:'项目使用地区'},
	                   {column:'rely',name:'项目依赖其他产品'},
	                   {column:'gitPath',name:'项目版本库地址'},
	                   {column:'branch',name:'分支'},
	                   {column:'projectCreateTime',name:'项目创建时间'},
	                   {column:'taskCreateTime',name:'任务创建时间'},
	                   {column:'plannedEndTime',name:'计划结束时间'},
	                   {column:'startTime',name:'任务开始时间'},
	                   {column:'endTime',name:'任务结束时间'},
	                   {column:'updateTime',name:'任务更新时间  '} ];
	
	
	var getTaskById = function(param){
		top.Proxy.getTaskById('getTaskById',param, function(res){
			showTask(task_detail,res.result);
			showFootPrints(param);
		}, function(){
			
		});
	};
	
	var showFootPrints = function(param){
		top.Proxy.getFootPrintsByTask(param, function(res){
			var div = $('<div>').appendTo('#task_detail_body');
			var table = $('<table>').addClass('footprints_table').appendTo(div);
			var tr = $('<tr>').appendTo(table);
			$('<th>').html('时间').appendTo(tr);
			$('<th>').html('状态').appendTo(tr);
			$('<th>').html('描述').appendTo(tr);
			$(res.result).each(function(i,footPrint){
				var tr = $('<tr>').appendTo(table);
				$('<td nowrap>').html(new Date(footPrint.updateTime).pattern("yyyy-MM-dd HH:mm:ss")).appendTo(tr);
				$('<td nowrap>').html(footPrint.status).appendTo(tr);
				$('<td>').html(footPrint.description).appendTo(tr);
			});
		}, function(){
			
		});
	};
	var getTaskLogById = function(param){
		top.Proxy.getTaskById('getTaskLogById',param, function(res){
			showTask(task_detail,res.result);
			showFootPrints(param);
		}, function(){
			alert("取得单个任务出错");
		});
	};
	
	var showTask = function(taskColumns,taskDetail){
		$('#task_detail_body').html('');
		var li;
		var ul = $('<ul>').appendTo('#task_detail_body');
		$(taskColumns).each(function(i,task){
			var showValue = taskDetail[task.column];
			 if(task.column=="process"){
				var status=taskDetail.taskStatus;
				if(status ==0){
					showValue = '<img  src="../images/status-wait.png"><span class="statusSpan">等待 </span>';
				}else if(status==1){
					showValue ='<img  src="../images/status-doing.gif"><span class="statusSpan">进行中</span>';
				}else if(status==2){
					showValue ='<img src="../images/status-doing.gif"><span class="statusSpan">--测试</span>';
				}else if(status==3){
					showValue ='<img src="../images/status-success.png"><span class="statusSpan">已完成</span>';
				}else{
					showValue ='<img src="../images/status-wait.png"></span>';
				}
			}
			else if(task.column=="projectCreateTime"||task.column=="taskCreateTime"||task.column=="plannedEndTime" ){
					showValue = new Date(showValue).pattern("yyyy-MM-dd");
			}
			else if( task.column=="updateTime"){
					showValue = new Date(showValue).pattern("yyyy-MM-dd HH:mm:ss");
			}
			 
			else if( task.column=="startTime"||task.column=="endTime" ){
				if(  showValue!=null   )
					showValue = new Date(showValue).pattern("yyyy-MM-dd");
				else
					showValue ='';
			}
		
		
			li = $('<li>').addClass('row').appendTo(ul);
			if(i%2==0){
				li.css('background-color','#f3f3f3');
			}
			$('<span>').addClass('col-md-4').html(task.name).appendTo(li);
			$('<span>').addClass('col-md-8').html(showValue).appendTo(li);
		});
	};
	$('#close_detail').click(function(){
		$('#task_list_div').css('right','1em');
		$('#task_detail_div').hide();
	});

    var _timeGrap = function(startDate,endDate) {
    	var l  = new Date(endDate)-new Date(startDate);
    	if(new Date(endDate) > new Date(startDate)){
    		var h = Math.floor(l/(60*60*1000));
        	var m=Math.floor((l/(60*1000))-h*60);
        	var s =Math.floor(l/1000-h*60*60-m*60);
        	var timeStr = (h>=0 && h<=9)? ("0" + h):(h);
        	timeStr +=  (m>=0 && m<=9)? (":0" + m):(":" + m);
        	timeStr +=  (s>=0 && s<=9)? (":0" + s):(":" + s);
        	return timeStr;
    	}else{
    		return '';
    	}
    };
    
    var _timePattern = function(mm) {
        if(mm != "" && mm != null) {
            var reg = new RegExp("^[0-9]*$");
            if (reg.test(mm)) {
	            var l  = mm/25;
		    	var h = Math.floor(l/(60*60));
		    	var m=Math.floor((l/(60))-h*60);
		    	var s =Math.floor(l-h*60*60-m*60);
		    	var timeStr = (h>=0 && h<=9)? ("0" + h):(h);
		    	timeStr +=  (m>=0 && m<=9)? (":0" + m):(":" + m);
		    	timeStr +=  (s>=0 && s<=9)? (":0" + s):(":" + s);
		    	return timeStr;
	    	}else{
	    		return '';
	    	}
        }else{
        	return '';
        }
    };
    var _timePattern = function(mm, type) {
    	
    	var part = 25;
    	if( type==4 || type == 6)
    		part =50;
    	else if( type==7)
    		part =100;
    	else if( type==8)
    		part =120;
    	
        if(mm != "" && mm != null) {
            var reg = new RegExp("^[0-9]*$");
            if (reg.test(mm)) {
	            var l  = mm/part;
		    	var h = Math.floor(l/(60*60));
		    	var m=Math.floor((l/(60))-h*60);
		    	var s =Math.floor(l-h*60*60-m*60);
		    	var timeStr = (h>=0 && h<=9)? ("0" + h):(h);
		    	timeStr +=  (m>=0 && m<=9)? (":0" + m):(":" + m);
		    	timeStr +=  (s>=0 && s<=9)? (":0" + s):(":" + s);
		    	return timeStr;
	    	}else{
	    		return '';
	    	}
        }else{
        	return '';
        }
    };
    
    var changeCss=function( comp , bob){
    	if(bob)
		{
    		comp.attr("disabled", false);
    		comp.removeClass('buttonDisabled');
    		comp.addClass('buttonMethod');
		}else
		{
			comp.attr("disabled", true);
			comp.removeClass('buttonMethod');
			comp.addClass('buttonDisabled');
		}
    }
    var  __markOperationPanel = function(task ) {
		$('#deleteTask').attr("disabled", false);
		
		console.log( task );
		
	  
		changeCss( $('#startTask'),  task.startTime==null )
		changeCss( $('#complateTask'), ( task.startTime!=null && task.endTime==null ) )
		
		
//		 
		changeCss( $('#updateUser'),  task.endTime==null  )
		 
		$('#modifyPriority').attr("disabled", false);
		$('#updateUser').attr("disabled", false);
		$('#updatePlanEndTime').attr("disabled", false);
		$('#stopTask').attr("disabled", false);
//		$('#export').removeClass('buttonDisabled');
//    	$('#export').addClass('buttonMethod');
        	 
       
    };
    
    var __operationClick=function(type,path,taskid,actorname){
    	if(type==0){
//    		if(confirm("选中任务将被永久删除，不能恢复,确定要删除？")){
//        		var param = {
//        				taskId: taskid,
//        				status: _task.status
//        				};
//    			top.Proxy.deleteTask(param, function(res){
//        			__queryList();
//        		}, function(){
//        			alert("任务删除失败");
//        		});
//    		}
    	}else if(type==1){
    		var assignActor = $("#assignActorA").val();
    		var priorityA = $("#priorityA").val();
    		if(priorityA != 8){
    			assignActor = "";
    		}
    		top.Proxy.updatePriority(taskid,priorityA,assignActor, function(res){
   			 $("#ActorHidden").attr("hidden", true);
			 //$('#assignActor').attr("disabled", "disabled");
			 $("#actorDes").attr("hidden", true);
    			__queryList();
    		}, function(){
    			alert("优先级调整及指定Actor失败");
    		});
    	}else if(type==2){
    		window.open("../rest/task/exportReport?taskId="+_task.taskId+"&isTask="+_task.isTask,"_blank");
    		
    	}else if(type==11){
    		window.open("../rest/task/exportReportExcel?taskId="+_task.taskId+"&isTask="+_task.isTask,"_blank");
    	}else if(type==3){
    		top.Proxy.againCancel(taskid,actorname,function(res){
    			__queryList();
    		}, function(){
    			alert("任务取消失败");
    		});
    		
    	}else if(type==4){
    		top.Proxy.redoTask(taskid, function(res){
    			__queryList();
    		}, function(){
    			alert("任务重试失败");
    		});
    		
    	}else if(type==5){
    		top.Proxy.taskResend(taskid,actorname, function(res){
    			__queryList();
    		}, function(){
    			alert("质检结果重发失败");
    		});
    	}else if(type==6){
    		window.open("../page/uqc_report.html?taskId="+taskid,"_blank");
    	}else if(type == 7){
    		var failDescription = $("#failDescription").val().trim();
    		if(failDescription.length <= 0){
    			alert("请填写手动归档备注");
    			return false;
    		};
    		if(failDescription.length > 150){
    			alert("您输入的手动归档备注过长，请不要大于150个字符");
    			return false;
    		}
    		var param = {
    				taskId: taskid,
    				failDescription: failDescription
    		};
    		top.Proxy.completeTask(param, function(){
    	    	divArchive.hide();
    	    	$(".black_overlay").hide();
    			__queryList();
    		}, function(){
    			alert("手动归档失败");
    		});
    	}
    	$(".black_overlay").hide();
    };
    
	var _valdateUserPermission = function(permissions ){
		if( permissions.indexOf('任务管理')>=0){
			return true;
		}
		return false;
	};
	
	 $("#userValdateBtn").click(function() {
		 if( $('#vupass').val().trim().length==0){
			 alert("请输入用户密码");
			 return;
		 }
		 var param={
					userId:$('#vuserId').val(),
					passWord :$('#vupass').val()
				};
		 top.Proxy.getUser(param, function(res) {
			if( res.total!=1)
			{
				alert("用户验证失败,请核对用户信息");
				return;
			}
			var user = res.result[0];
			if( $('#vupass').val() != user.passWord)
			{
				alert("用户验证失败,密码不匹配");
				return;
			}
			var rol = {
					'rolename' : user.roleId 
				};
				top.Proxy.getRoles(rol, function(res) {
					role=res.result[0];
					if(!_valdateUserPermission(role.permissions) ){
						alert("用户验证失败,没有操作此功能的权限");
						return false;
					}
					validate_User_dialog.hide();
					if(handleBtn == '优先级调整及指定Actor'){
						divPriority.show();
						handleBtn = '';
					}else if(handleBtn == "手动归档"){
						divArchive.show();
						$("#failDescription").val("");
					}else{
						__operationClick(type, "", taskid, actorname);
					}
				}, function() {
					alert("查询角色出错");
				});
		}, function() {
			alert("用户验证失败");
		});
	 });
	 //当指定的优先级为8的时候，可以指定Actor
	 $("#priorityA").change(function(){
		 if($("#priorityA").val() == 8){
			 $("#ActorHidden").attr("hidden", false);
			 $("#actorDes").attr("hidden", true);
		 }else{
			 $("#ActorHidden").attr("hidden", true);
			 $("#actorDes").attr("hidden", true);
		 }
	 });
	 
	$("#assignActorA").change(function(){
		var assignActor = $(this).val();
		if(assignActor.length > 0){
			top.Proxy.queryActorStatus({actorName: assignActor},function(data){
				var task = data.result;
				if(task.taskId.length > 0){
					$("#actorDes").attr("hidden", false);
					var programCode = task.programCode;
					var subtitleLanguageCode = task.subtitleLanguageCode;
					var audioLanguageCode = task.audioLanguageCode;
					var segmentIndex = task.segmentIndex;
					var md5Process = task.md5Process;
					var process = task.process;
					if(task.programCode.length <= 0){
						$("#actorDes").html("该"+assignActor+"没有任务在执行");
					}else{
						if(subtitleLanguageCode.length <= 0){
							subtitleLanguageCode = "";
						}
						if(audioLanguageCode.length <= 0){
							audioLanguageCode = "";
						}
						if(segmentIndex.length <= 0){
							segmentIndex = "";
						}
						if(md5Process.length <= 0){
							md5Process = 0;
						}
						if(process.length <= 0){
							process = 0;
						}
						var taskID = programCode+"_" +subtitleLanguageCode+"_"+audioLanguageCode+"_"+segmentIndex;
						if(task.taskType == 'MD_5_TASK'){
							$("#actorDes").html("该"+assignActor+"正在执行MD5任务<br>节目关键字为"+taskID+"<br>任务的进度为"+md5Process+"%");
						}else{
							var taskStatus = "";
							if(task.taskType == "QC_TASK"){
								taskStatus = "质检任务";
							}else{
								taskStatus = "质检与MD5合一任务";
							}
							$("#actorDes").html("该"+assignActor+"正在执行"+taskStatus+"<br>节目关键字为"+taskID+"<br>任务的进度为"+process+"%");
						}
					}
				}else{
					$("#actorDes").html("该"+assignActor+"没有任务在执行");
				}
			},function(){
				alert("取得指定Actor的状态出错");
			});
		}
	});
    //进行取消操作
	validate_User_dialog.find('.glyphicon-trash').click(function() {
		validate_User_dialog.hide();
		$(".black_overlay").hide();
	});
	validate_User_dialog.find('.edit_close').click(function() {
		validate_User_dialog.hide();
		$(".black_overlay").hide();
	});
	//指定Actor页面的操作
	$("#priorityOK").click(function(){
    	var prriority=$("#prioritySel").val();
    	var data={
    			priority:prriority,
    			taskId:taskid
    	};
    	top.Proxy.generalPostAjax('task/update' , data ,  function(res) {
			__queryList();
		}, function(e) {
			console.log( e )
			alert("分页查询任务出错");
		});
    	divPriority.hide();
    	$(".black_overlay").hide();
	});
	
	$("#priorityCancel").click(function(){
		handleBtn = '';
    	divPriority.hide();
    	$(".black_overlay").hide();
	});

	divPriority.find(".edit_close").click(function(){
		handleBtn = '';
    	divPriority.hide();
    	$(".black_overlay").hide();
	});
	//手动归档页面的操作
	$("#archiveOK").click(function(){
    	type = 7;
    	__operationClick(type, "", taskid, actorname);
    	handleBtn = '';
	});
	
	$("#archiveCancel").click(function(){
		handleBtn = '';
		divArchive.hide();
    	$(".black_overlay").hide();
	});

	divArchive.find(".edit_close").click(function(){
		handleBtn = '';
		divArchive.hide();
    	$(".black_overlay").hide();
	});
	
	
	
	 $('#startTask').click(function(){
		 var ok ="";
	    	ok = confirm("任务开始！");
			
	    	if(!ok){
	    		return false;
	    	}else{
	    		type=0;
	    		var queryConditions = new Array();//查询条件
	    		var data={
	    				 conditions:queryConditions,
	    				 relation: 'AND',
	    		};
	    		data.conditions.push({
					name: 'task_id',
					logic:'=',
					value: taskid
				});
	    		top.Proxy.generalPostAjax('task/start' , data ,  function(res) {
	    			__queryList();
	    		}, function(e) {
	    			console.log( e )
	    			alert("分页查询任务出错");
	    		});
	    	}
	 });
	 $('#complateTask').click(function(){
		 var ok ="";
	    	ok = confirm("确定要把这个任务做完成操作吗？");
			
	    	if(!ok){
	    		return false;
	    	}else{
	    		type=0;
	    		var queryConditions = new Array();//查询条件
	    		var data={
	    				 conditions:queryConditions,
	    				 relation: 'AND',
	    		};
	    		data.conditions.push({
					name: 'task_id',
					logic:'=',
					value: taskid
				});
	    		
	    		top.Proxy.generalPostAjax('task/complate' , data ,  function(res) {
	    			__queryList();
	    		}, function(e) {
	    			console.log( e )
	    			alert("分页查询任务出错");
	    		});
	    	}
		 
	 });
	 
    $('#deleteTask').click(function(){
    	var ok ="";
    	ok = confirm("确定要把这个任务做"+"删除"+"操作吗？");
		
    	if(!ok){
    		return false;
    	}else{
    		type=0;
    		var queryConditions = new Array();//查询条件
    		var data={
    				 conditions:queryConditions,
    				 relation: 'AND',
    		};
    		data.conditions.push({
				name: 'task_id',
				logic:'=',
				value: taskid
			});
    		
    		top.Proxy.generalPostAjax('task/remove' , data ,  function(res) {
    			__queryList();
    		}, function(e) {
    			console.log( e )
    			alert("分页查询任务出错");
    		});
    	}
    });
     
    $('#modifyPriority').click(function(){
		 
		divPriority.show();
		  
		 
		
//		if(priorityA != 8){
//			assignActor = "";
//		}
//		top.Proxy.updatePriority(taskid,priorityA,assignActor, function(res){
//			 $("#ActorHidden").attr("hidden", true);
//		 //$('#assignActor').attr("disabled", "disabled");
//		 $("#actorDes").attr("hidden", true);
//			__queryList();
//		}, function(){
//			alert("优先级调整及指定Actor失败");
//		});
		
		//填充Actor指定信息
//		$('<option value="">请选择Actor</option>').appendTo("#assignActorA");
//		top.Proxy.queryActors(function(data){
//			$(data.result).each(function(key, actor){
//				if(actor.actorStatus == '正常'){
//					var option = '<option value="'+actor.actorName+'">'+actor.actorName+'</option>';
//					$(option).appendTo("#assignActorA");
//				}
//			});
//		},function(){
//			
//		});
		
//		var paramID = {
//				taskId: _task.taskId
//		};
//		top.Proxy.getTaskById('getTaskById',paramID, function(data){
//			if(data.result.statusType == "等待"){
//				var ok = confirm("确定要这个任务做 "+"优先级调整及指定Actor"+"操作吗？");
//		    	if( !ok){
//		    		return;
//		    	}else{
//		    		handleBtn = '优先级调整及指定Actor';
//		    		type=1;
//		    		validateUser();
//		    	}
//			}else{
//				alert("该任务正在执行中，不能进行进行优先级调整及指定Actor操作");
//			}
//		},function(){
//			alert("该任务未查询到");
//		});
    
    });
    $('#export').click(function(){
    	__operationClick(2,"质检结果导出","",taskid,actorname);
    });
    $('#exportExcel').click(function(){
    	__operationClick(11,"导出Excel","",taskid,actorname);
    });
    
     
    $('#cacelRedo').click(function(){
    	var ok = confirm("确定要这个任务做 "+"取消"+"操作吗？");
    	if( !ok){
    		return;
    	}else{
    		type=3;
    		validateUser();
    	}
    });
/*    $('#taskRedo').click(function(){
    	var ok = confirm("确定要这个任务做 "+"重试"+"操作吗？");
    	if( !ok){
    		return;
    	}else{
    		type=4;
    		validateUser();
    	}
    });*/
    $('#reSend').click(function(){
    	var ok = confirm("确定要这个任务做 "+"质检结果重发"+"操作吗？");
    	if( !ok){
    		return;
    	}else{
    		type=5;
    		validateUser();
    	}
    });
    $('#compare').click(function(){
    	var ok = confirm("确定要这个任务做 "+"质检结果展示"+"操作吗？");
    	if( !ok){
    		return;
    	}else{
    		type=6;
    		__operationClick(type, "", taskid, actorname);
    	}
    });
    $("#archive").click(function(){
    	var ok = confirm("确定要将这个任务手动归档吗？");
    	if(!ok){
    		return ;
    	}else{
    		handleBtn = '手动归档';
    		type = 7;
    		validateUser();
    	}
    });
    
	var __updatePages = function(total) {
		var divPage = divList.find('footer');
		divPage.empty();
		var divPageSum = $('<div style="position: absolute;left: 0;color:#529F02;padding: 0.3em 0.5em;margin:0.3em;">').appendTo(divPage);
		
		var totalPage = parseInt(total / pageSize);
		if (totalPage == 0 || total % pageSize != 0) {
			totalPage ++;
		}
		divPageSum.html("<img src='../images/page-flower.png'>  页数" + pageNo + "/" + totalPage +' ， '+ "总记录数 " + total+"，每页显示：");
		var select = $('<select>').val(pageSize).appendTo(divPageSum);
		var sizeArray = [5,10,15,20,50,100];
		$(sizeArray).each(function(i,size){
			var sizeOption = $('<option>').html(size).val(size).appendTo(select);
			if(pageSize==size){
				sizeOption.attr('selected','selected');
			}
		});
		$(select).change(function(){
			pageSize = $(this).val();
			pageNo = 1;
			__queryList();
		});
		var divPageDetail = $('<div class="pageDetail">').appendTo(divPage);
		var ulPage = $('<ul class="pagination pagination-sm">').appendTo(divPageDetail);
		var pageData = [{
			Name:'首页',
			PageNum:1
		}];
		pageNo == 1 ? pageData.push({Name: '上一页', PageNum: 0}) : pageData.push({Name: '上一页', PageNum: pageNo-1});
		if(pageNo>4){
			for (var i = pageNo - 2; i <= (pageNo + 2> totalPage ? totalPage : pageNo + 2); i++) {
				pageData.push({Name : i,PageNum : i});
			}
		}else if(pageNo <= 4 && totalPage > 1){
			for(var j = 1; j <= ( totalPage >= 4 ? 4 : totalPage); j++){
				pageData.push({Name:j,PageNum:j});
			}
		}
		pageNo == totalPage ? pageData.push({Name: '下一页',PageNum : 0}) : pageData.push({Name: '下一页', PageNum: pageNo+1});
		pageData.push({Name: '尾页',PageNum: totalPage});
		$(pageData).each(function(index , page){
			var lipage = $('<li>').appendTo(ulPage);
			var apage = $('<a>').css('cursor','pointer').html(page.Name).appendTo(lipage);
			if(pageNo==page.Name){
				apage.css('color','#fff').css('background-color','#529F02');
			}
			if(page.PageNum > 0){
				apage.click(function(){
					__openPage(page.PageNum);
				});
			}
		});
	};
	
	var __openPage = function(pageno){
		divList.find('footer').empty();
		pageNo = pageno;
		__queryList();
	};
	$(".form_datetime").datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0		 
 });
	//完成导出excel
	$('#exportTasks').click(function(){
	
		var programCode = $('#proCode').val();
		var taskId = $('#taskId').val();
		var audioLanguageCode = $('#audioLanguageCode').val();
		var subtitleLanguageCode = $('#subtitleLanguageCode').val();
		var taskType = $('#taskType').val();
		var programName = $('#proName').val().trim();
		var statusType = $('#status').val();
		var columnCode = $('#columnCode').val();
		var channelCode = $('#channelCode').val();
		var systemId = $("#producer").val();
		var playStartTime = $("#playStartTime").val();
		var playEndTime = $("#playEndTime").val();
		var submitStartTime = $("#submitStartTime").val();
		var submitEndTime = $("#submitEndTime").val();
		var priority = $("#priority").val();
		var actorName = $("#actor").val();
		var minVideoScore = $('#minVideoScore').val();
		var maxVideoScore = $('#maxVideoScore').val();
		var minAudioScore = $('#minAudioScore').val();
		var maxAudioScore = $('#maxAudioScore').val();
		
		var flag = true;
		if(playStartTime.length > 0 && playEndTime.length > 0){
			var startT = new Date(playStartTime);
			var endT = new Date(playEndTime);
			if(startT > endT){
				alert("结束日期不能小于开始日期");
				flag = false;
			}
		}
		if(submitStartTime.length > 0 && submitEndTime.length > 0){
			var startT = new Date(submitEndTime);
			var endT = new Date(submitEndTime);
			if(startT > endT){
				alert("结束日期不能小于开始日期");
				flag = false;
			}
		}
		var reg = /^[1-9]\d*$/;
		if(reg.test(minVideoScore)|| reg.test(maxVideoScore)){
			alert("质检视频得分请填写数字");
			flag = false;
		}
		if(reg.test(minAudioScore)|| reg.test(maxAudioScore)){
			alert("质检音频频得分请填写数字");
			flag = false;
		}
		if(flag){
			if(programName.length > 0){
				programName = '%25'+programName+'%25';
			}
			if(columnCode.length > 0){
				columnCode = '%25'+columnCode+'%25';
			}
			if(programCode.length > 0){
				programCode = '%25'+programCode+'%25';
			}
			if(taskId.length > 0){
				taskId = '%25'+taskId+'%25';
			}
			var url = "programCode="+programCode+"&audioLanguageCode="+audioLanguageCode+"&subtitleLanguageCode="+subtitleLanguageCode+"&taskType="+taskType+"&taskId="+taskId+
			"&programName="+programName+"&statusType="+statusType+"&columnCode="+columnCode+"&channelCode="+channelCode+"&systemId="+systemId+"&playStartTime="+playStartTime+
			"&playEndTime="+playEndTime+"&priority="+priority+"&actorName="+actorName+"&minVideoScore="+minVideoScore+"&maxVideoScore="+maxVideoScore+"&minAudioScore="+minAudioScore+
			"&maxAudioScore="+maxAudioScore+"&submitStartTime="+submitStartTime+"&submitEndTime="+submitEndTime;
			window.location.href="../rest/task/getTaskExcel?"+url;
		}
	});
	
	__queryList();
	
	$(".queryTable").bind("keydown",function(e){
        // 兼容FF和IE和Opera    
    var theEvent = e || window.event;    
    var code = theEvent.keyCode || theEvent.which || theEvent.charCode;    
    if (code == 13) {    
        //回车执行查询
    		$('#queryBtn').click();
        }    
	});
});